import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

// https://vite.dev/config/
export default defineConfig({
    plugins: [
        vue(),
    ],
    define:{
        global: 'window'
    },
    resolve: {
        alias: {
            '@': fileURLToPath(new URL('./src', import.meta.url))
        }
    },
    server: {
        port: 5173,
        open: true,
        proxy: {
            '/8101': {
                target: 'http://localhost:8101',
                changeOrigin: true,
                rewrite: (path) => path.replace(/^\/8101/, ''),
            },
            '/8201': {
                target: 'http://localhost:8201',
                changeOrigin: true,
                rewrite: (path) => path.replace(/^\/8201/, ''),
            },
            '/8301': {
                target: 'http://localhost:8301',
                changeOrigin: true,
                rewrite: (path) => path.replace(/^\/8301/, ''),
            },
            '/8401': {
                target: 'http://localhost:8401',
                changeOrigin: true,
                rewrite: (path) => path.replace(/^\/8401/, ''),
            },
        }
    }
})
